package com.study.zjh.smartrefreshdemo.base;

import android.support.v7.app.AppCompatActivity;

import com.billy.android.swipe.SmartSwipe;
import com.billy.android.swipe.SmartSwipeWrapper;
import com.billy.android.swipe.SwipeConsumer;

import java.util.List;

public class BaseActivity extends AppCompatActivity {

    @Override
    public void onBackPressed() {
        SmartSwipeWrapper wrapper = SmartSwipe.peekWrapperFor(this);
        if (wrapper != null) {
            List<SwipeConsumer> consumers = wrapper.getAllConsumers();
            if (!consumers.isEmpty()) {
                for (SwipeConsumer consumer : consumers) {
                    if (consumer != null) {
                        if (consumer.isLeftEnable()) {
                            consumer.smoothLeftOpen();
                            return;
                        } else if (consumer.isTopEnable()) {
                            consumer.smoothTopOpen();
                            return;
                        }
                    }
                }
            }
        }
        super.onBackPressed();
    }
}
